package com.tuananh.radnom.gwt.shared.dto;

import java.util.ArrayList;
import java.util.HashMap;

import com.sencha.gxt.data.shared.TreeStore;

public class NetInterfaceDTO extends NetElementDTO {
	MyBaseDTO ipAddress;
	MyBaseDTO macAddress;
	ArrayList<NetServiceDTO> netServices;

	public MyBaseDTO getIpAddress() {
		return ipAddress;
	}

	public void setIpAddress(MyBaseDTO ipAddress) {
		this.ipAddress = ipAddress;
	}

	public MyBaseDTO getMacAddress() {
		return macAddress;
	}

	public void setMacAddress(MyBaseDTO macAddress) {
		this.macAddress = macAddress;
	}

	public ArrayList<NetServiceDTO> getNetServices() {
		return netServices;
	}

	public void setNetServices(ArrayList<NetServiceDTO> netServices) {
		this.netServices = netServices;
	}

	@Override
	public MyBaseDTO addToTreeStore(MyBaseDTO root, String prefix,
			TreeStore<MyBaseDTO> store) {
		// TODO Auto-generated method stub
		if (root != null) {
			parentDTO = super.addToTreeStore(root, prefix, store);
			if (ipAddress!=null) ipAddress.addToTreeStore(parentDTO, "IP Address", store);
			if (macAddress!=null) macAddress.addToTreeStore(parentDTO, "MAC Address", store);
			if (netServices != null && netServices.size() > 0) {
				MyBaseDTO listService = new MyBaseDTO("Services",
						"List Service");
				validateAndAdd(this, "List Service", listService, store);
				for (NetServiceDTO netService : this.netServices) {
					netService.addToTreeStore(listService, "", store);
				}
			}
		}
		return parentDTO;
	}
}
